package common.ui
{
	import flash.display.InteractiveObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class MovieClipButton
	{
		public function MovieClipButton()
		{
		}
		public static function init(mc:MovieClip,isHand:Boolean=true):void{
			mc.stop();
			mc.getChildByName("area").addEventListener(MouseEvent.MOUSE_OVER,showMovieClipOver);
			mc.getChildByName("area").addEventListener(MouseEvent.MOUSE_OUT,showMovieClipOut);
			mc.getChildByName("area").addEventListener(MouseEvent.MOUSE_DOWN,showMovieClipDown);
			if(isHand == true){
				Sprite(mc.getChildByName("area")).buttonMode = true;
				Sprite(mc.getChildByName("area")).useHandCursor = true;
			}
		}
		public static function getArea(mc:MovieClip):InteractiveObject{
			var area:InteractiveObject = mc.getChildByName("area") as InteractiveObject;
			return area;
		}
		private static function showMovieClipOver(event:MouseEvent):void{
			var mc:MovieClip = event.currentTarget.parent as MovieClip;
			mc.gotoAndStop(2);
		}
		private static function showMovieClipOut(event:MouseEvent):void{
			var mc:MovieClip = event.currentTarget.parent as MovieClip;
			if(mc.mouseEnabled == false) return;
			mc.gotoAndStop(1);
		}
		private static function showMovieClipDown(event:MouseEvent):void{
			var mc:MovieClip = event.currentTarget.parent as MovieClip;
			mc.gotoAndStop(3);
		}
	}
}